// dlg.txt

begintalkscript;

variables;

begintalknode 1;
	state = -1;
	nextstate = -1;
	condition = get_sdf(5,4) == 0;
	question = "special";
	text1 = "You enter the West Foundry Core. This is where the bulk of the creations stored in the Foundry are kept. They are generally only taken out for testing, discipline, and the occasional bit of fresh air in the Promenade.";
	text2 = "It is like a huge hotel for creations. They get cells. Fresh bedding. Serviles prepare and bring meals. The creations don't necessarily like being kept here, but they are properly cared for.";
	text3 = "And, since this is where most of the creations were, this is where the Presence was able to create a great deal of chaos. The halls are dark and strewn with trash. The combined reek of blood, waste, and smoke makes you gag.";
	text4 = "You can hear all of the creations in the darkness, hissing and fighting. And hunting.";
	action = SET_SDF 5 4 1;

begintalknode 2;
	state = -1;
	nextstate = -1;
	condition = get_sdf(5,12) == 0 && gf(2,3) == 0;
	question = "special";
	text1 = "This passage ends in a huge stone door. It is sealed shut. The controls to open it are on the other side.";
	text2 = "Unless someone lets you in, you won't be able to get through here. You should probably go hunt the Presence in a different area.";
	action = SET_SDF 5 12 1;

begintalknode 3;
	state = -1;
	nextstate = -1;
	condition = get_sdf(5,13) == 0 && gf(5,18) == 0;
	question = "special";
	text1 = "This passage ends in a huge stone door. It is sealed shut. The controls to open it are on the other side. A sign next to it reads, _Control Center._";
	text2 = "The Shapers are very careful to make sure that nothing can lock them away from their own controls. There must be another way to get this door open hidden somewhere in the complex.";
	action = SET_SDF 5 13 1;
	
begintalknode 4;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";

begintalknode 5;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "There is a clawbug chained to this post, waiting patiently to be called into service. It is calm and quiet.";
	text3 = "There is a clawbug chained to this post. Something seems to be agitating it. It strains against the chain, hissing and spitting. Letting it loose right now would be a bad idea.";
	code =
		if ((gf(5,2) > 0) || (gf(2,3) != 1))
			rs(3);
			else rs(1);
	break;

begintalknode 6;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The obelisk says:";
	text2 = "  CREATION DROP OFF/COLLECTION";
	text3 = "  Secure creations here. Report in Creation Care.";

begintalknode 7;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The obelisk says:";
	text2 = "  CREATION CARE";
	text3 = "    Health Maintenance - East";
	text4 = "    Food Preparation - West";

begintalknode 8;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You try to make small talk, but you don't have any luck. The soldier indicated that you should speak with Sergeant Lysette.";
	text2 = "Probably worried that you'll try to give some orders and lead them all in an assault on the rogues. Probably a valid concern.";
	code =
		 if (gf(7,7) > 0)
		 	rs(2);
	break;
		
begintalknode 10;
	state = -1;
	nextstate = 10;
	condition = 1;
	question = "Name";
	text1 = "There is a soldier hiding in this storage closet, curled up on the floor next to a smashed set of shelves. When he sees you in the dim light, he jumps to his feet.";
	text2 = "_Saved ... Saved ... I can't believe it. I am Private Kahl. I've been hiding here for ... too long. I survived. You are here? Here to help me?_";
	text5 = "Private Kahl says, _Is it time? Are you rescuing me now?_";
	action = INTRO;
	code =
		sf(5,6,1);
	break;
	
begintalknode 11;
	state = 10;
	nextstate = 11;
	condition = 1;
	question = "What happened to you?";
	text1 = "_I don't know. I was patrolling. Doing my job. Then all the creations went mad. I thought it would be all right. Then the cell doors opened. Who opened the cell doors?_";
	text2 = "_Then I hid._";

begintalknode 12;
	state = 11;
	nextstate = -1;
	condition = 1;
	question = "Someone let the creatures out of their cells?";
	text1 = "_It is madness. I can't believe it either. But it happened. How could someone have done something so foolish? Unless a rogue creation did it somehow ... But that isn't possible._";

begintalknode 13;
	state = 11;
	nextstate = -1;
	condition = 1;
	question = "What happened then?";
	text1 = "_I saw it. You have to believe me. I am not mad. I saw rogues dragging out power spirals. I saw them making the spirals explode. They smashed the spirals and died. It broke down the walls, letting more rogues out._";
	text2 = "_I know this isn't possible. I know rogues can't act like that. But I saw it!_";

begintalknode 14;
	state = 11;
	nextstate = -1;
	condition = 1;
	question = "How did you hide?";
	text1 = "_It was hard. I moved from cell to cell. I avoided the swarms. I waited until the rogues fought each other, and I slipped away._";
	text2 = "_I don't see how I survived, though. Sometimes, I thought they knew I was there. They knew, and they let me live. They were playing with me. They enjoyed seeing me running like a rabbit._";
	text3 = "_But you are here. You can help me escape. Please?_";

begintalknode 15;
	state = 10;
	nextstate = -1;
	condition = 1;
	question = "Can you help me fight the rogues?";
	text1 = "Private Kahl backs into the corner and shudders. You notice how hungry and tired he is. He's not much of a soldier right now. He might never be a decent soldier again.";

begintalknode 16;
	state = 10;
	nextstate = -1;
	condition = 1;
	question = "All right. Make a break for the exit. I will escort you.";
	text1 = "He draws his blade and holds it out with a shaking hand. _All right. I am running now. Please stay with me? Don't let them get me?_";
	text2 = "He runs for the exit.";
	action = END_TALK;
	code =	
		sf(5,5,1);
		sf(5,1,1);
		set_attitude(12,3);
		activate_hidden_group(1);
	break;
	
begintalknode 17;
	state = 10;
	nextstate = -1;
	condition = 1;
	question = "Just stay here for now.";
	text1 = "_No! Please!_ He whimpers for a little bit. Then he gives up. _Don't forget about me? Please come get me soon?_";
	action = END_TALK;

	
begintalknode 20;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You inspect the scrying crystal. It is completely dark. The Presence must not be anywhere nearby.";
	text2 = "Mehken says, _We should go. Lots of rogues, but not our prey. If we stay to the south, we should avoid most of them._";
	code =
		if (char_in_party(47) < 0)
			rs(2);
	break;
	
begintalknode 21;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You inspect the scrying crystal. It is glowing gently. This must be where the Presence fled.";
	text2 = "Mehken looks at the crystal and nods. _This is where we must hunt. Many rogues out there in the dark._";
	text3 = "She thinks for a moment. _Have not been here in a long time. I think there are control rooms and labs to the north. We should hunt there._";
	code =
		if (char_in_party(47) < 0) {
			rs(2); rs(3);
			}
	break;
	
begintalknode 22;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";
	
begintalknode 23;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "__";
//

begintalknode 30;
	state = -1;
	nextstate = 30;
	condition = 1;
	question = "Sergeant Lysette";
	text1 = "There are several human soldiers sitting around this fire. They have been chopping up and burning furniture to keep warm in the chilly halls of the Foundry Core.";
	text2 = "The rogues are keeping a safe distance from the soldiers. The ones who didn't died quickly. The warriors aren't complacent, though. They are keeping their weapons handy.";
	text3 = "The ranking soldier present nods to you when you approach. _I know you? Well, doesn't matter. I'm Sergeant Lysette. We've been waiting for someone to come take charge. Hope you're it._";
	text5 = "Sergeant Lysette throws another chair leg on the fire and watches the halls for wandering rogues. Content that nothing nasty is emerging from the shadows, she says, _What else you need?_";
	action = INTRO;

begintalknode 31;
	state = 30;
	nextstate = 33;
	condition = gf(2,3) == 0;
	question = "Describe the situation.";
	text1 = "_Calm. Whatever is driving the creations mad, it isn't here._ She points at the clawbug chained nearby. _Cruncher there has been calm for a while._";

begintalknode 32;
	state = 30;
	nextstate = 35;
	condition = gf(2,3) == 1 && gf(5,2) == 0;
	question = "Describe the situation.";
	text1 = "_Not good. Whatever is making the creations go mad, it's nearby. Been here for a while. I can hear the rogues howling. I don't like how things are looking._";

begintalknode 33;
	state = 30;
	nextstate = -1;
	condition = gf(5,2) > 0;
	question = "Describe the situation.";
	text1 = "_Calm. Quieter than it's been. The rogues that are left are real scared. Stay far away. You've made my life a lot easier. I'll tell you that._";
	text2 = "_Wish you didn't have to kill any of my soldiers to do it, though._";
	code =
		if (gf(5,7) == 0)
			rs(2);
	break;
	
begintalknode 34;
	state = 30;
	nextstate = 31;
	condition = 1;
	question = "How long have you been here?";
	text1 = "_Since the madness started. Captain Valenta sent us to keep anything from slipping into Isenwood's Spire._ She points to the passage to the south.";
	text2 = "_Thought we'd have a far worse time of it than we did. Thought we'd be attacked all the time. Hasn't worked out that way._";

begintalknode 35;
	state = 31;
	nextstate = 32;
	condition = 1;
	question = "The rogues haven't attacked you?";
	text1 = "_A few did. They were easy work. The rest stay back. Pretty calm and restrained, for rogues. When they weren't blowing things up._";
	text2 = "";

begintalknode 36;
	state = 31;
	nextstate = -1;
	condition = 1;
	question = "And you're just sitting here?";
	text1 = "_Yes, until we get orders to do otherwise. We patrol a little. Poke around. But we're not likely to go running around in the dark without Shaper help. We're just outsiders. We can't be trusted to do something like that._";
	text2 = "_With the Presence gone, though, I don't think we'll be out here for long._";
	code =
		if (gf(2,3) < 4)
			rs(2);
	break;
	
begintalknode 37;
	state = 32;
	nextstate = -1;
	condition = 1;
	question = "Blowing things up?";
	text1 = "She points to the north. _There have been a lot of explosions out there since all the creations went mad. The rogues did something with the Shaper equipment. It's volatile stuff, if you do the wrong thing._";
	text2 = "_Somehow, the rogues managed to do that wrong thing. A lot._";

begintalknode 38;
	state = 33;
	nextstate = -1;
	condition = 1;
	question = "Will you help me to hunt the Presence?";
	text1 = "_It's not here. When it is, Cruncher goes funny. Strains at the chains. And if it's not here, we aren't moving._";

begintalknode 39;
	state = 30;
	nextstate = -1;
	condition = gf(1,11) == 3 && gf(5,6) == 0;
	question = "I'm looking for Private Kahl. Seen him?";
	text1 = "She shakes her head. _He's not one of mine. Heard of him, though. He was out there when things got mad. You're probably just hunting for a body. Doubt he could survive out there alone._";

begintalknode 40;
	state = 35;
	nextstate = -1;
	condition = 1;
	question = "How do you know it's here?";
	text1 = "She points at the clawbug chained nearby. _Cruncher there has been going mad. Straining against the chain. She's as calm a clawbug as you could want, normally. No, something wrong is in the air._";

begintalknode 41;
	state = 35;
	nextstate = 36;
	condition = gf(5,9) == 0;
	question = "I am hunting for the Presence. Where should I go?";
	text1 = "_Well, there are two control centers in this area. That'd be a good place to look. One in the northwest corner, one in the northeast._";
	text2 = "_The northeast one is sealed up. Saw that on a patrol. But you might be able to open it up from the northwest. That's the way Shapers make these places, you can't get shut out of anywhere._";

begintalknode 42;
	state = 36;
	nextstate = 30;
	condition = 1;
	question = "Thanks for the information.";
	text1 = "She seems relieved that you don't ask for anything else. _Glad to help. Anything else?_";

begintalknode 43;
	state = 36;
	nextstate = 30;
	condition = get_stat(20) < 4 && gf(5,10) == 0;
	question = "I need you to help me get there.";
	text1 = "You try to convince her to send some soldiers to help you. You aren't convincing enough. _No. Sorry. We got orders. We watch the passage to the Spire. Can't just ignore our orders._";
	text2 = "_Anything else you need?_";

begintalknode 44;
	state = 36;
	nextstate = 37;
	condition = get_stat(20) >= 4 && gf(5,10) == 0;
	question = "I am working directly for Shaper Rawal. I command you to help me get there.";
	text1 = "You command her with your most confident tone of voice. As much as she wants to keep following orders and prevent her soldiers from going to face the rogues, she can't ignore the will of the Shapers.";
	text2 = "She sighs. _All right. I have no choice, not if it's what Rawal wants. I'll send Skimpole and Guppy to help you. They won't be under your orders, though. They assault, you follow. Say when you're ready._";
	text3 = "Skimpole and Guppy don't look happy.";
	
begintalknode 45;
	state = 37;
	nextstate = -1;
	condition = 1;
	question = "I'm not ready yet.";
	text1 = "_Well, get ready. If I'm going to send my men into danger, I want them to have full backup._";
	action = END_TALK;
	
begintalknode 46;
	state = 37;
	nextstate = -1;
	condition = 1;
	question = "I am ready. Give the order.";
	text1 = "She barks, _Skimpole. Guppy. Go and seize control of the northwest control room. Try to keep this ... person safe while you do it. Don't get killed. Go._";
	text2 = "The two soldiers rise and begin the attack. They motion for you to follow.";
	action = END_TALK;
	code =
		sf(5,10,1);
	break;
	

begintalknode 47;
	state = 35;
	nextstate = -1;
	condition = gf(5,9) > 0 && gf(5,18) == 0;
	question = "I am hunting for the Presence. Where should I go?";
	text1 = "_Go back to the northwest lab and find a way to unlock the door to the main control room._";


begintalknode 48;
	state = 35;
	nextstate = 39;
	condition = gf(5,9) > 0 && gf(5,18) > 0;
	question = "I am hunting for the Presence. Where should I go?";
	text1 = "_From the sound of things, the best place to look that hasn't been searched already is the control center. It's in the northeast corner of the complex._";

begintalknode 49;
	state = 39;
	nextstate = 30;
	condition = 1;
	question = "Thanks for the information.";
	text1 = "She seems relieved that you don't ask for anything else. _Glad to help. Anything else?_";

begintalknode 50;
	state = 39;
	nextstate = 30;
	condition = get_stat(20) < 5 && gf(5,11) == 0;
	question = "I need you to help me get there.";
	text1 = "You try to convince her to send some soldiers to help you. You aren't convincing enough. _No. Sorry. We got orders. We watch the passage to the Spire. Can't just ignore our orders._";
	text2 = "_Anything else you need?_";

begintalknode 51;
	state = 39;
	nextstate = 40;
	condition = get_stat(20) >= 5 && gf(5,11) == 0;
	question = "I am working directly for Shaper Rawal. I command you to help me get there.";
	text1 = "You command her with your most confident tone of voice. As much as she wants to keep following orders and prevent her soldiers from going to face the rogues, she can't ignore the will of the Shapers.";
	text2 = "_I hope you take better care than you have so far, though. I don't appreciate anyone getting my soldiers killed._";
	text3 = "She sighs. _All right. I have no choice, not if it's what Rawal wants. I'll send Carstone and Jarndyce to help you. They won't be under your orders, though. They assault, you follow. Say when you're ready._";
	text4 = "Carstone and Jarndyce look like they've just received a death sentence.";
	code =
		if (gf(5,7) == 0)
			rs(2);
	break;
	
begintalknode 52;
	state = 40;
	nextstate = -1;
	condition = 1;
	question = "I'm not ready yet.";
	text1 = "_Well, get ready. If I'm going to send my soldiers into that hornet's nest, I want them to have full backup._";
	action = END_TALK;	
	
begintalknode 53;
	state = 40;
	nextstate = -1;
	condition = 1;
	question = "I am ready. Give the order.";
	text1 = "She barks, _Carstone. Jarndyce. Go and seize control of the northeast control center. Try to keep this ... person safe while you do it. Don't get killed. Go._";
	text2 = "The two soldiers rise and begin the attack. They motion for you to follow.";
	action = END_TALK;
	code =
		sf(5,11,1);
	break;
	

//

begintalknode 60;
	state = -1;
	nextstate = 60;
	condition = is_group() && gf(7,26) == 0 && gf(2,3) == 1 && gf(5,9) == 0 && gf(6,14) == 0;
	question = "Name";
	text1 = "The door to the north has a sign next to it: _Spawning Laboratory._";
	text3 = "When you get close to the door, it slides open slightly. When you get closer, it opens more. After your experiences in the eastern part of the Foundry Core, this is all too familiar.";
	text4 = "Once again, the Presence is challenging you. Taunting you. Inviting you into a trap.";
	action = SET_SDF 6 14 2;
	
begintalknode 61;
	state = 60;
	nextstate = -1;
	condition = 1;
	question = "Don't enter.";
	text1 = "You decide to stay outside. Sadly, as the Presence is in control of the complex, if you wish to hunt it you will probably have to fight it on its own terms.";
	action = END_TALK;
	
begintalknode 62;
	state = 60;
	nextstate = -1;
	condition = 1;
	question = "Go through the door.";
	text1 = "You approach the door. Unsurprisingly, it opens all the way. You step through.";
	action = END_TALK;
	code =
		sf(7,26,1);
		sf(7,27,1);
		sf(5,19,1);
		char_clear_action(1000);
			
		toggle_cutscene(1);
	break;

begintalknode 64;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "As the door behind you slides shut, you evaluate the situation.";
	text2 = "There are four alcoves in this chamber. Each contains a clawbug, only partially completed. The act of creation seems to have been interrupted. The creatures are insubstantial. They stand motionless on the platforms.";
	text3 = "Then power begins to flow through one of the conduits on the ground. It enters the clawbug in the northeast alcove. The creature instantly begins to look more real. The claws begin to move.";
	text4 = "Soon, the creature will be complete.";

begintalknode 65;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "Now that the clawbugs are dead, you have once again met the challenge of the Presence. You hear a clicking noise. It comes from the three doors leading away from this laboratory.";
	text2 = "Private Skimpole approaches the door. It opens. He steps through, hurrying to return to the safety of his camp.";
	text3 = "Private Guppy departs, her work here done.";
	code =
		if (gf(5,10) == 0) {
			rs(2); rs(3);
			}
		if (char_ok(62) == FALSE)
				rs(2);
		if (char_ok(63) == FALSE)
				rs(3);
		if ((gf(5,10) > 0) && (char_ok(62))) {
			erase_char(62);
			spawn_creature(54);
			set_name(62,"Private Skimpole");
			}
		if ((gf(5,10) > 0) && (char_ok(63))) {
			erase_char(63);
			spawn_creature(55);
			set_name(63,"Private Guppy");
			}
		sf(5,10,0);
	break;
			
	
//

begintalknode 70;
	state = -1;
	nextstate = 70;
	condition = is_group() && gf(7,28) == 0 && gf(2,3) == 1 && gf(5,2) == 0 && gf(5,18) > 0 && gf(6,14) == 0;
	question = "Name";
	text1 = "The door to the north has a sign next to it: _Control Center._";
	text3 = "When you get close to the door, it slides open slightly. As you get closer, your mind starts to cloud over. You have experienced enough to recognize the signs. The Presence is near.";
	action = SET_SDF 6 14 2;
	
begintalknode 71;
	state = 70;
	nextstate = -1;
	condition = 1;
	question = "Don't enter.";
	text1 = "You decide to stay outside. Sadly, as the Presence is in control of the complex, if you wish to hunt it you will probably have to fight it on its own terms.";
	action = END_TALK;
	
begintalknode 72;
	state = 70;
	nextstate = -1;
	condition = 1;
	question = "Go through the door.";
	text1 = "You approach the door. Unsurprisingly, it opens all the way. You step through.";
	action = END_TALK;
	code =
		sf(7,28,1);
		sf(7,29,1);
		sf(5,20,1);
		char_clear_action(1000);
			
		toggle_cutscene(1);
	break;

begintalknode 74;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "You inspect the control center for this area of the Foundry. It's a very large hall, probably used for meetings. Right now, the only creature here is the servant mind that keeps things running.";
	text2 = "Then you see the glowing mist that surrounds the servant mind, and you realize where the Presence has landed.";
	text3 = "This is worrying. Servant minds are expected to channel a lot of power. This means that, when they go rogue, they can be very dangerous. The mind is twitching and flailing in its tray, trying to regain control of itself.";
	text4 = "The mind looks at you and says, in a raspy voice, _Intruder. Please. Destroy me._";
	text5 = "Then the Presence takes partial control of the creature. In an instant, it surrounds itself with a shield of energy. Creations begin to take form on the platforms to the north.";
	
begintalknode 75;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The servant mind's twitching becomes more intense. The creature is strong enough to keep the Presence from taking full control, but this is very painful for it.";
	text2 = "It says, _Trying ... trying to break free. Will not ... be rogue._";
	text3 = "The Presence takes full control again. Another swarm of creations appears on the northern platforms.";
	
begintalknode 76;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "The servant mind lets out a long, agonized screech. _No! No! No!_ It looks very pale. Its eyes glaze over. It regains control for a moment. The shield around it fades.";
	text2 = "Then the Presence takes control, only to find that the mind has lost much of its power. Its essence is drained. The shield is gone.";
	text3 = "It still has some strength left, though. Enough to summon another swarm of bugs.";
	
begintalknode 77;
	state = -1;
	nextstate = -1;
	condition = 1;
	question = "special";
	text1 = "At last, you have heavily damaged the servant mind. The Presence can no longer use its body. As it did before, it begins to flee, a long wisp of mist emerging from the pale body.";
	text2 = "The servant mind quietly says, _Am free. Thank you. Am in control. Am loyal. Can ... end. Invader dies ... with me._ It closes its eyes and wills itself to die before the Presence can completely escape.";
	text3 = "As before, part of its form is chopped off, trapped in the body of the servant mind. The rest of it, looking fainter than before, flows through the east wall.";
	text4 = "You have banished the Presence from another region.";
	text5 = "You look around and find that your soldier escort has slipped away, probably returning to safety.";
	code =
		if (gf(5,11) == 0) {
			rs(5);
			}
			else if ((char_ok(64) == FALSE) && (char_ok(65) == FALSE))
				rs(5);
		if ((gf(5,11) > 0) && (char_ok(64))) {
			erase_char(64);
			spawn_creature(56);
			set_name(64,"Private Carstone");
			}
		if ((gf(5,11) > 0) && (char_ok(65))) {
			erase_char(65);
			spawn_creature(57);
			set_name(65,"Private Jarndyce");
			}
			
		sf(5,11,0);
	break;
		